<template>
	
	<form @submit="submit" :data-action="`/api/monitoringStation/save?stationId=${param.stationId}`">
			
			<view class="fixAuto bb middle">
				<view class="w80">
					站房面积
				</view>
				<view>
					<input v-if="!disabled" type="number" name="x.area|站房面积|amount" v-model="data.area" :disabled="disabled" placeholder="请输入站房面积,单位:㎡">
					<view v-else>
						{{data.area}} 
					</view>
				</view>
				<view class="w20">
					㎡
				</view>
			</view>
			
			
			<block v-for="( item , index) in formList" :key="index">
				<simple-picker :title="item.title" :name="item.name" :value="data[item.valueKey]" :disabled="disabled"></simple-picker>
			</block>
			
			
			
			<view class="plr100 pd30" v-if="!disabled">
				<button form-type="submit" class="btn block rds23">
					保存记录
				</button>
			</view>
		</form>

	</layout>
</template>

<script>
	export default {
		data() {
			return {
				param:{stationId:""} ,
				data : {} ,
				disabled : true ,
				formList : [
					{title : "空调" , name : "x.airConditioner|空调|0~200" , valueKey : "airConditioner" } ,
					{title : "消防设施" , name : "x.fireFalicities|消防设施|0~200" , valueKey : "fireFalicities" } ,
					{title : "稳压电源" , name : "x.regulatedPowerSupply|稳压电源|0~200" , valueKey : "regulatedPowerSupply" } ,
					{title : "防雷接地" , name : "x.LightningProtection|防雷接地|0~200" , valueKey : "LightningProtection" } ,
					{title : "照明" , name : "x.light|照明|0~200" , valueKey : "light" } ,
					{title : "温湿度计" , name : "x.hygrothermograph|温湿度计|0~200" , valueKey : "hygrothermograph" } ,
					{title : "上下水" , name : "x.waters|上下水|0~200" , valueKey : "waters" } 
				]
			}
		},
		onLoad(params) {
			this.param = params ;
			var role = uni.getStorageSync("role");
			this.disabled = role != 2 ;
			this.loadData();
		},
		methods: {
			
			loadData:function(e){
				var data = {id:this.param.stationId} ;
				this.kit.get("/api/monitoringStation/info",data,res => {
					this.data = res.data || {};
				});
			},
			
			submit:function(e){
				this.form.submit(e , this.success);
			},
			
			success:function(e){
				this.kit.goSuccessBack("保存成功");
			}
		}
	}
</script>
<style>
	page{
		background-color: #fff;
	}
</style>